﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Collections;

namespace GVCSMTemplates
{
    public class CalculateTableInformation
    {

       public DataTable tableRowsForSingleScreenWith2Sessions(DataTable dt)
        {
            DataTable resultTable = new DataTable();
            resultTable = dt.Clone();
            resultTable.Clear();

            object[] iRow1 = dt.Rows[10].ItemArray;
            resultTable.Rows.Add(iRow1);
          
           return resultTable;
        }

        public DataTable tableRowsForSingleScreenWith1Session(DataTable dt)
        {
            DataTable resultTable = new DataTable();
            resultTable = dt.Clone();
            resultTable.Clear();
            object[] iRow = dt.Rows[0].ItemArray;
            resultTable.Rows.Add(iRow);
            return resultTable;
        }

        public DataTable retrieveTableForNormalTemplate(DataTable normalTemplateDataTable)
        {
            int rowCount = normalTemplateDataTable.Rows.Count;
            DataTable dtNormal = new DataTable();

            if (rowCount >= 10)
            {
                IniFile ini = new IniFile(@"c:\BOX\Signbox\played.ini");
                String value = ini.ReadValue("Normal Template", "played");
                if (value == "played2")
                {
                    dtNormal = tableRowsForSingleScreenWith1Session(normalTemplateDataTable);
                    ini.WriteValue("Normal Template", "played", "played1");
                }
                else
                {
                    dtNormal = tableRowsForSingleScreenWith2Sessions(normalTemplateDataTable);
                    ini.WriteValue("Normal Template", "played", "played2");
                }
            }
            else
            {
                dtNormal = tableRowsForSingleScreenWith1Session(normalTemplateDataTable);
            }
            return dtNormal;
        }

       
        
    }
  }